function getLocTime(nS,flag) {
    var date = new Date(nS * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
	if(flag){
		if(date.indexOf('-')!=-1){
			date = date.substr(0,date.indexOf(" "));
		}
	}
	return date;
}

$(function(){
	$(".timestamp").each(function(i){
		var time  = $(this).html();
		var full  = $(this).attr("full");
		if(time!=null && time!=""){
			if(full=="true"){
				$(this).html(getLocTime(time,true));
			}else{
				$(this).html(getLocTime(time,false));
			}
		}
	});
});
GLOBAL_UPLOADID = "";
GLOBAL_UPLOADMAX = 0;
function fileupload(uploadid,ext,sizeLimit){
	GLOBAL_UPLOADID = uploadid;
	if(ext==null || ext==""){ ext="*.rar;*.zip;*.doc;*.png;*.gif;*.jpeg;*.jpg"; }
	if(sizeLimit==null || sizeLimit=="") sizeLimit = 2*1024*1024; //默认两兆
	GLOBAL_UPLOADMAX = sizeLimit;
 	$("#"+uploadid).uploadify({
		'uploader'       : './js/uploadify/uploadify.swf',
		'script'         : './upload.php',
		'cancelImg'      : './images/cancel.png',
		'fileDesc'       : '允许类型('+ext+')',
		'fileExt'        : ext,
		'folder'         : 'uploads',
		'queueID'        : 'div'+uploadid,
		'sizeLimit'      : sizeLimit,
		'auto'           : true,
		'multi'          : false,
		'onComplete'     : uploadfinish,
		'onError'		 : showError
	});
}
function showError(event,queueID,fileObj,errorObj){
	if(errorObj.type=='File Size'){
		alert("文件过大，最大允许"+GLOBAL_UPLOADMAX/1024+"KB，请调整后重新上传！");
	}else if(errorObj.type=='HTTP'){
		alert("网络错误，请重试");
	}else if(errorObj.type=='IO'){
		alert("文件读取失败，请重试");
	}
}